<?php
/**
 * @file
 * Selects one of the localized resources based on the user's locale.
 *
 * If the locale-specific resource file is not found, the default locale's
 * resources are used.
 *
 * Usage:
 *  - A page that wants to use localized resources should include/require this
 *    page once and only once.
 *
 * Parameter(s):
 *  - None.
 *
 * Global variable(s) set:
 *  - None.
 *
 * Global variable(s) unset:
 *  - None.
 *
 * Exception(s):
 *  - None.
 *
 * This file includes/requires:
 *  - h_locale.php
 *  - l10n_<locale>.php
 */

// header file(s) ==============================================================
require_once "h_locale.php";


// constant(s) =================================================================
//! Filename prefix of locale-specific resource file.
define("LOCALE_FILENAME_PREFIX", "l10n_");
//! Filename suffix of locale-specific resource file.
define("LOCALE_FILENAME_SUFFIX", ".php");


// implementation ==============================================================
$filename = LOCALE_FILENAME_PREFIX . $locale_user . LOCALE_FILENAME_SUFFIX;
if (true == file_exists($filename)) {
  // the requested locale exists
  // => retreive resources for the requested locale
  require_once $filename;
} else {
  // the requested locale does not exist
  // => retreive resources for the default locale
  require_once LOCALE_FILENAME_PREFIX
               . $LOCALES[DEF_LOCALE][LOCALE_INDEX_ll_CC]
               . LOCALE_FILENAME_SUFFIX;
}
?>
